package com.hksj.tdengine.taos.config;


import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.hksj.tdengine.taos.interceptor.TaosDynamicTableNameInnerInterceptor;
import com.hksj.tdengine.taos.interceptor.TaosTableNameHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zengke
 * @version 1.0
 * @see MybatisPlusConfig
 * @since 2024/7/5 10:57
 */

@Configuration
public class MybatisPlusConfig {

    @Bean
    public MybatisPlusInterceptor taosMybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();

        // 动态表名插件
        TaosDynamicTableNameInnerInterceptor dynamicTableNameInnerInterceptor = new TaosDynamicTableNameInnerInterceptor();
        dynamicTableNameInnerInterceptor.setTableNameHandler(new TaosTableNameHandler());
        interceptor.addInnerInterceptor(dynamicTableNameInnerInterceptor);

        return interceptor;
    }

}
